/*
 * @Author: intellectual-seeker 3336339701@qq.com
 * @Date: 2025-08-25 22:07:43
 * @LastEditors: intellectual-seeker 3336339701@qq.com
 * @LastEditTime: 2025-08-26 07:32:59
 * @FilePath: /code/lesson29/test.c
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <signal.h>
#include <stdio.h>

//volatile关键字
volatile int g_flag = 0;

void handler(int signo)
{
    printf("signo is : %d\n", signo);

    int old_gflag = g_flag;
    g_flag = 1;
    printf("g_flag : %d -> %d\n", old_gflag, g_flag);    
}

//int g_flag = 0;//函数若是使用了全局变量，全局变量必须在函数之前定义

int main()
{
    signal(SIGINT, handler);

    while(!g_flag);

    printf("process quit normal\n");

    return 0;
}